-
Notifications
You must be signed in to change notification settings - Fork 2
feat: real-time predictions and distance calculations #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: real-time predictions and distance calculations #118
Conversation
…ver response order
…h the vehicle's position was measured
- refactor the impl of GetNextStop function to get the next stop based on the stop sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements real-time predictions and distance calculations for transit systems by integrating GTFS realtime data with scheduled transit information. The changes add support for predicting arrival/departure times based on real-time trip updates and calculating distances between vehicles and stops.
Key changes:
- Added real-time trip and vehicle lookup functionality with hash maps for improved performance
- Implemented predicted arrival/departure time calculations using GTFS realtime trip updates
- Added distance calculation methods for determining remaining distance to stops and number of stops away
- Refactored next stop finding logic to use vehicle's current stop sequence instead of position-based calculations
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
internal/restapi/vehicles_helper.go | Added helper functions for vehicle data extraction and removed redundant timestamp calculations |
internal/restapi/trips_helper.go | Updated trip building logic to use active trip ID and simplified next stop finding |
internal/restapi/arrival_and_departure_for_stop_handler.go | Implemented real-time predictions and distance calculations for arrival/departure responses |
internal/models/trip_details.go | Reorganized TripStatusForTripDetails struct fields alphabetically |
internal/gtfs/realtime.go | Added lookup map rebuild functions for efficient real-time data access |
internal/gtfs/gtfs_manager_mock.go | Updated mock to maintain vehicle lookup consistency |
internal/gtfs/gtfs_manager.go | Added lookup maps and helper methods for real-time data access |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if numberOfStopsAwayPtr != nil { | ||
numberOfStopsAway = *numberOfStopsAwayPtr | ||
} else { | ||
numberOfStopsAway = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using -1 as a magic number to indicate unknown stops away is unclear. Consider defining a constant like const UnknownStopsAway = -1
or using a pointer type to distinguish between 0 stops away and unknown.
Copilot uses AI. Check for mistakes.
Fix: #87